<!DOCTYPE html>
<html lang="zh-CN" color-mode=light>


<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>SpringBoot 配置文件加载源码学习探究 - 树朾的开源技术分享</title>
  <meta name="apple-mobile-web-app-capable" content="yes" />
  <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
  <meta name="google" content="notranslate" />
  <meta name="keywords" content="开源, 分享">
  <meta name="description" content="SpringBoot 在项目根路径添加 config ...">
  <meta name="author" content="scwang90">
  <link rel="icon" href="/images/icons/favicon.ico">
  
  
  
  
  

  
<link rel="stylesheet" href="/css/style.css">


  
    
<link rel="stylesheet" href="https://at.alicdn.com/t/font_1445822_p6ry5n7lrr.css">

  

  
    
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/fancybox/3.5.7/jquery.fancybox.min.css">

  

  
    
      
        
        
<link rel="stylesheet" href="https://cdn.bootcss.com/highlight.js/9.18.1/styles/xcode.min.css" name="highlight-style" mode="light">

      
        
        
<link rel="stylesheet" href="https://cdn.bootcss.com/highlight.js/9.18.1/styles/solarized-dark.min.css" name="highlight-style" mode="dark">

      
  

  <script>
    var CONFIG = window.CONFIG || {};
    var ZHAOO = window.ZHAOO || {};
    CONFIG = {
      isHome: false,
      fancybox: true,
      pjax: false,
      loading: {
        gif: '/images/theme/loading.gif',
        lottie: ''
      },
      lazyload: {
        enable: true,
        only_post: 'false',
        loading: {
          gif: '/images/theme/loading.gif',
          lottie: ''
        }
      },
      donate: {
        enable: false,
        alipay: '/images/donate/pay_alipay.jpg',
        wechat: '/images/donate/pay_wxpay.jpg',
        tencent: '/images/donate/pay_tencent.jpg'
      },
      galleries: {
        enable: true
      },
      fab: {
        enable: true,
        always_show: false
      },
      carrier: {
        enable: true
      },
      daovoice: {
        enable: false
      },
      preview: {
        background: {
          default: '',
          api: ''
        },
        motto: {
          default: '我在开了灯的床头下，想问问自己的心啊。',
          typing: true,
          api: 'https://v2.jinrishici.com/one.json',
          data_contents: '["data","content"]'
        },
      },
      qrcode: {
        enable: true,
        type: 'url',
        image: 'https://pic.izhaoo.com/weapp-code.jpg',
      },
      toc: {
        enable: true
      },
      scrollbar: {
        type: 'default'
      },
      notification: {
        enable: false,
        delay: 4500,
        list: '',
        page_white_list: '',
        page_black_list: ''
      },
      search: {
        enable: false,
        path: ''
      }
    }
  </script>

  

  

<meta name="generator" content="Hexo 6.2.0"></head>

<body class="lock-screen">
  <div class="loading" id="loading"></div>
  
    


  <nav class="navbar">
    <div class="left">
      
        <i class="iconfont iconhome j-navbar-back-home"></i>
      
      
        <i class="iconfont iconqrcode j-navbar-qrcode"></i>
      
      
        <i class="iconfont iconmoono" id="color-toggle" color-toggle="light"></i>
      
      
    </div>
    <div class="center">SpringBoot 配置文件加载源码学习探究</div>
    <div class="right">
      <i class="iconfont iconmenu j-navbar-menu"></i>
    </div>
    
      <div id="qrcode-navbar"></div>
    
  </nav>

  
  

<nav class="menu">
  <div class="menu-container">
    <div class="menu-close">
      <i class="iconfont iconbaseline-close-px"></i>
    </div>
    <ul class="menu-content"><li class="menu-item">
        <a href="/ " class="underline "> 首页</a>
      </li><li class="menu-item">
        <a href="/galleries/ " class="underline "> 摄影</a>
      </li><li class="menu-item">
        <a href="/archives/ " class="underline "> 归档</a>
      </li><li class="menu-item">
        <a href="/tags/ " class="underline "> 标签</a>
      </li><li class="menu-item">
        <a href="/categories/ " class="underline "> 分类</a>
      </li><li class="menu-item">
        <a href="/about/ " class="underline "> 关于</a>
      </li></ul>
    
      <div class="menu-copyright"><p>Powered by <a target="_blank" href="https://github.com/scwang90">scwang90</a>  |  Theme - <a target="_blank" href="https://github.com/izhaoo/hexo-theme-zhaoo">zhaoo</a></p> <p><a target="_blank" href="http://beian.miit.gov.cn/"><span>黔ICP备2021004317号-1</span></a><span>  |  </span><a target="_blank" href="http://www.beian.gov.cn/portal/registerSystemInfo" style="display:inline-block;text-decoration:none;height:20px;line-height:20px;"><img class="lazyload" data-original="/images/icons/icon-filing.png" src="https://www.beian.gov.cn/img/new/gongan.png"/> <span> 贵公网安备 52010202002539号</span></a></p></div>
    
  </div>
</nav>
  <main id="main">
  <div class="article-wrap">
    
      <div class="row container container-lg">
        <div class="col-xl-2"></div>
        <div class="col-xl-8"><article class="article">
  <div class="wrap">
    <section class="head">
  <img   class="lazyload" data-original="/images/theme/post-image.jpg" src=""  draggable="false">
  <div class="head-mask">
    <h1 class="head-title">SpringBoot 配置文件加载源码学习探究</h1>
    <div class="head-info">
      <span class="post-info-item"><i class="iconfont iconcalendar"></i>五月 23, 2024</span>
      
      <span class="post-info-item"><i class="iconfont iconfont-size"></i>17573</span>
    </div>
  </div>
</section>
    <section class="main">
      <section class="content article-entry">
        
          
        
        <p>SpringBoot 在项目根路径添加 config 配置，有些项目运行的时候配置不起作用，本文对SpringBoot源码配置文件加载进行解读学习探究</p>
<h2 id="SpringBoot-集成-NacosRegister-源码启动顺序"><a href="#SpringBoot-集成-NacosRegister-源码启动顺序" class="headerlink" title="SpringBoot 集成 NacosRegister 源码启动顺序"></a>SpringBoot 集成 NacosRegister 源码启动顺序</h2><ol>
<li>@SpringBootApplication 注解 main 函数执行</li>
<li>SpringBootApp() 构造函数<ul>
<li><p>getSpringFactoriesInstances(BootstrapRegistryInitializer.class) 加载</p>
<ul>
<li><p>SpringFactoriesLoader.loadFactoryNames(type, classLoader)</p>
</li>
<li><p>SpringFactoriesLoader.loadSpringFactories </p>
<ul>
<li>Enumeration<URL> urls &#x3D; classLoader.getResources(‘META-INF&#x2F;spring.factories’)</li>
<li>urls.foreach<ul>
<li><p>jar:file:&#x2F;C:&#x2F;Users&#x2F;SCWANG&#x2F;.m2&#x2F;repository&#x2F;io&#x2F;springboot&#x2F;nacos&#x2F;nacos-config&#x2F;2.2.4&#x2F;nacos-config-2.2.4.jar!&#x2F;META-INF&#x2F;spring.factories</p>
</li>
<li><p>Properties properties &#x3D; PropertiesLoaderUtils.loadProperties(new UrlResource(url))</p>
<ul>
<li>#fillProperties(new Properties(), resource)<ul>
<li>resource.getInputStream()<ul>
<li>URLConnection con &#x3D; this.url.openConnection()</li>
<li>return con.getInputStream();</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
<li><p>properties:</p>
<ul>
<li>org.springframework.context.ApplicationContextInitializer -&gt; <ul>
<li>com.alibaba.nacos.config.server.utils.PropertyUtil</li>
</ul>
</li>
</ul>
</li>
<li><p>jar:file:&#x2F;C:&#x2F;Users&#x2F;SCWANG&#x2F;.m2&#x2F;repository&#x2F;io&#x2F;springboot&#x2F;nacos&#x2F;nacos-core&#x2F;2.2.4&#x2F;nacos-core-2.2.4.jar!&#x2F;META-INF&#x2F;spring.factories</p>
</li>
<li><p>properties:</p>
<ul>
<li><p>org.springframework.boot.SpringApplicationRunListener -&gt;</p>
<ul>
<li>com.alibaba.nacos.core.code.SpringApplicationRunListener</li>
</ul>
</li>
<li><p>org.springframework.context.ApplicationListener -&gt; </p>
<ul>
<li>com.alibaba.nacos.core.code.StandaloneProfileApplicationListener</li>
</ul>
</li>
</ul>
</li>
<li><p>jar:file:&#x2F;C:&#x2F;Users&#x2F;SCWANG&#x2F;.m2&#x2F;repository&#x2F;io&#x2F;springboot&#x2F;nacos&#x2F;nacos-sys&#x2F;2.2.4&#x2F;nacos-sys-2.2.4.jar!&#x2F;META-INF&#x2F;spring.factories</p>
</li>
<li><p>properties:</p>
<ul>
<li>org.springframework.context.ApplicationContextInitializer -&gt; <ul>
<li>com.alibaba.nacos.sys.utils.ApplicationUtils</li>
</ul>
</li>
</ul>
</li>
<li><p>… 后续循环看下面章节</p>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
<li><p>BootstrapRegistryInitializer.class：</p>
<ul>
<li>加载到：<ul>
<li>org.springframework.cloud.bootstrap.RefreshBootstrapRegistryInitializer</li>
<li>org.springframework.cloud.bootstrap.TextEncryptorConfigBootstrapper</li>
</ul>
</li>
<li>#createSpringFactoriesInstances 创建实例<ul>
<li>0 &#x3D; {RefreshBootstrapRegistryInitializer@1822} </li>
<li>1 &#x3D; {TextEncryptorConfigBootstrapper@1823}</li>
</ul>
</li>
</ul>
</li>
<li><p>getSpringFactoriesInstances(ApplicationContextInitializer.class) 加载</p>
</li>
<li><p>ApplicationContextInitializer.class</p>
</li>
<li><p>赋值到 bootstrapRegistryInitializers 字段</p>
</li>
<li><p>META-INF&#x2F;spring.factories</p>
</li>
</ul>
</li>
<li>SpringBootApp#run 函数执行<ul>
<li>执行 prepareEnvironment 准备变量<ul>
<li>#getOrCreateEnvironment </li>
<li>#applicationContextFactory.createEnvironment(this.webApplicationType)<ul>
<li>getFromSpringFactories 读取</li>
</ul>
</li>
</ul>
</li>
<li>根据 webApplicationType 和 applicationContextFactory 创建环境对象</li>
<li>SpringBootApp.listeners 触发 environmentPrepared 监听<ul>
<li><h2 id="com-alibaba-nacos-core-code-SpringApplicationRunListener-nacos-监听到事件"><a href="#com-alibaba-nacos-core-code-SpringApplicationRunListener-nacos-监听到事件" class="headerlink" title="com.alibaba.nacos.core.code.SpringApplicationRunListener [nacos 监听到事件]"></a>com.alibaba.nacos.core.code.SpringApplicationRunListener [nacos 监听到事件]</h2></li>
<li>EventPublishingRunListener 监听到 environmentPrepared<ul>
<li>使用 initialMulticaster 多播 ApplicationEnvironmentPreparedEvent 事件</li>
</ul>
</li>
<li>EnvironmentPostProcessorApplicationListener 接收到多播事件<ul>
<li>多个 EnvironmentPostProcessor 循环处理事件</li>
<li>ConfigDataEnvironmentPostProcessor 轮到处理事件<ul>
<li>ConfigDataEnvironmentContributors 和 Binder 一顿循环绕来绕去</li>
<li>然后 ConfigDataImporter 处理配置文件的 resolve</li>
<li>最终 StandardConfigDataLocationResolver resolve<ul>
<li>optional:file:.&#x2F;;optional:file:.&#x2F;config&#x2F;;optional:file:.&#x2F;config&#x2F;*&#x2F;</li>
<li>然后 #getReferencesForDirectory 函数拼接 目录和文件<ul>
<li>configNames 字段存储了配置文件的名称<ul>
<li>[“bootstrap”]</li>
<li>[“application”]</li>
</ul>
</li>
</ul>
</li>
<li>propertySourceLoaders 字段存储了 两种配置加载器<ul>
<li>YamlPropertySourceLoader (properties,xml)</li>
<li>PropertiesPropertySourceLoader (yml,yaml)</li>
<li>file:.&#x2F;application.yaml</li>
<li>file:.&#x2F;application.yml</li>
<li>file:.&#x2F;application.xml</li>
<li>file:.&#x2F;application.properties</li>
<li>file:.&#x2F;config&#x2F;application.yaml</li>
<li>file:.&#x2F;config&#x2F;application.yml</li>
<li>file:.&#x2F;config&#x2F;application.xml</li>
<li>file:.&#x2F;config&#x2F;application.properties</li>
<li>file:.&#x2F;config&#x2F;*&#x2F;application.yaml</li>
<li>file:.&#x2F;config&#x2F;*&#x2F;application.yml</li>
<li>file:.&#x2F;config&#x2F;*&#x2F;application.xml</li>
<li>file:.&#x2F;config&#x2F;*&#x2F;application.properties</li>
</ul>
</li>
<li>最终 #resolve(StandardConfigDataReference reference) 判断文件存在</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
<li>返回 ApplicationServletEnvironment 对象</li>
</ul>
</li>
<li>SpringBootApp 初始化结束</li>
</ul>
</li>
</ol>
<h2 id="spring-factories-循环读取完整版"><a href="#spring-factories-循环读取完整版" class="headerlink" title="spring.factories 循环读取完整版"></a>spring.factories 循环读取完整版</h2><ul>
<li><p>jar:file:&#x2F;C:&#x2F;Users&#x2F;SCWANG&#x2F;.m2&#x2F;repository&#x2F;io&#x2F;springboot&#x2F;nacos&#x2F;nacos-config&#x2F;2.2.4&#x2F;nacos-config-2.2.4.jar!&#x2F;META-INF&#x2F;spring.factories</p>
</li>
<li><p>Properties properties &#x3D; PropertiesLoaderUtils.loadProperties(new UrlResource(url))</p>
<ul>
<li>#fillProperties(new Properties(), resource)<ul>
<li>resource.getInputStream()<ul>
<li>URLConnection con &#x3D; this.url.openConnection()</li>
<li>return con.getInputStream();</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
<li><p>properties:</p>
<ul>
<li>org.springframework.context.ApplicationContextInitializer -&gt; <ul>
<li>com.alibaba.nacos.config.server.utils.PropertyUtil</li>
</ul>
</li>
</ul>
</li>
<li><p>jar:file:&#x2F;C:&#x2F;Users&#x2F;SCWANG&#x2F;.m2&#x2F;repository&#x2F;io&#x2F;springboot&#x2F;nacos&#x2F;nacos-core&#x2F;2.2.4&#x2F;nacos-core-2.2.4.jar!&#x2F;META-INF&#x2F;spring.factories</p>
</li>
<li><p>properties:</p>
<ul>
<li><p>org.springframework.boot.SpringApplicationRunListener -&gt;</p>
<ul>
<li>com.alibaba.nacos.core.code.SpringApplicationRunListener</li>
</ul>
</li>
<li><p>org.springframework.context.ApplicationListener -&gt; </p>
<ul>
<li>com.alibaba.nacos.core.code.StandaloneProfileApplicationListener</li>
</ul>
</li>
</ul>
</li>
<li><p>jar:file:&#x2F;C:&#x2F;Users&#x2F;SCWANG&#x2F;.m2&#x2F;repository&#x2F;io&#x2F;springboot&#x2F;nacos&#x2F;nacos-sys&#x2F;2.2.4&#x2F;nacos-sys-2.2.4.jar!&#x2F;META-INF&#x2F;spring.factories</p>
</li>
<li><p>properties:</p>
<ul>
<li>org.springframework.context.ApplicationContextInitializer -&gt; <ul>
<li>com.alibaba.nacos.sys.utils.ApplicationUtils</li>
</ul>
</li>
</ul>
</li>
<li><p>jar:file:&#x2F;C:&#x2F;Users&#x2F;SCWANG&#x2F;.m2&#x2F;repository&#x2F;org&#x2F;springframework&#x2F;spring-beans&#x2F;5.3.33&#x2F;spring-beans-5.3.33.jar!&#x2F;META-INF&#x2F;spring.factories</p>
</li>
<li><p>properties:</p>
<ul>
<li>org.springframework.beans.BeanInfoFactory -&gt; <ul>
<li>org.springframework.beans.ExtendedBeanInfoFactory</li>
</ul>
</li>
</ul>
</li>
<li><p>jar:file:&#x2F;C:&#x2F;Users&#x2F;SCWANG&#x2F;.m2&#x2F;repository&#x2F;org&#x2F;springframework&#x2F;cloud&#x2F;spring-cloud-commons&#x2F;3.1.7&#x2F;spring-cloud-commons-3.1.7.jar!&#x2F;META-INF&#x2F;spring.factories</p>
</li>
<li><p>properties:</p>
<ul>
<li>org.springframework.boot.diagnostics.FailureAnalyzer” -&gt;<ul>
<li>org.springframework.cloud.configuration.CompatibilityNotMetFailureAnalyzer”</li>
</ul>
</li>
<li>pringframework.boot.env.EnvironmentPostProcessor” -&gt;<ul>
<li>org.springframework.cloud.client.HostInfoEnvironmentPostProcessor”</li>
</ul>
</li>
<li>pringframework.boot.autoconfigure.EnableAutoConfiguration” -&gt;<ul>
<li>org.springframework.cloud.client.CommonsClientAutoConfiguration</li>
<li>org.springframework.cloud.client.ReactiveCommonsClientAutoConfiguration</li>
<li>org.springframework.cloud.client.discovery.composite.CompositeDiscoveryClientAutoConfiguration</li>
<li>org.springframework.cloud.client.discovery.composite.reactive.ReactiveCompositeDiscoveryClientAutoConfiguration</li>
<li>org.springframework.cloud.client.discovery.simple.SimpleDiscoveryClientAutoConfiguration</li>
<li>org.springframework.cloud.client.discovery.simple.reactive.SimpleReactiveDiscoveryClientAutoConfiguration</li>
<li>org.springframework.cloud.client.hypermedia.CloudHypermediaAutoConfiguration</li>
<li>org.springframework.cloud.client.loadbalancer.AsyncLoadBalancerAutoConfiguration</li>
<li>org.springframework.cloud.client.loadbalancer.LoadBalancerAutoConfiguration</li>
<li>org.springframework.cloud.client.loadbalancer.LoadBalancerDefaultMappingsProviderAutoConfiguration</li>
<li>org.springframework.cloud.client.loadbalancer.reactive.LoadBalancerBeanPostProcessorAutoConfiguration</li>
<li>org.springframework.cloud.c”</li>
</ul>
</li>
</ul>
</li>
<li><p>jar:file:&#x2F;C:&#x2F;Users&#x2F;SCWANG&#x2F;.m2&#x2F;repository&#x2F;org&#x2F;springframework&#x2F;cloud&#x2F;spring-cloud-context&#x2F;3.1.7&#x2F;spring-cloud-context-3.1.7.jar!&#x2F;META-INF&#x2F;spring.factories</p>
</li>
<li><p>properties:</p>
<ul>
<li>org.springframework.boot.BootstrapRegistryInitializer” -&gt;<ul>
<li>org.springframework.cloud.bootstrap.RefreshBootstrapRegistryInitializer</li>
<li>org.springframework.cloud.bootstrap.TextEncryptorConfigBootstrapper”</li>
</ul>
</li>
<li>pringframework.boot.env.EnvironmentPostProcessor” -&gt;<ul>
<li>org.springframework.cloud.bootstrap.encrypt.DecryptEnvironmentPostProcessor</li>
<li>org.springframework.cloud.util.random.CachedRandomPropertySourceEnvironmentPostProcessor”</li>
</ul>
</li>
<li>pringframework.cloud.bootstrap.BootstrapConfiguration” -&gt;<ul>
<li>org.springframework.cloud.bootstrap.config.PropertySourceBootstrapConfiguration</li>
<li>org.springframework.cloud.bootstrap.encrypt.EncryptionBootstrapConfiguration</li>
<li>org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration</li>
<li>org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration”</li>
</ul>
</li>
<li>pringframework.context.ApplicationListener” -&gt;<ul>
<li>org.springframework.cloud.bootstrap.BootstrapApplicationListener</li>
<li>org.springframework.cloud.bootstrap.LoggingSystemShutdownListener</li>
<li>org.springframework.cloud.context.restart.RestartListener”</li>
</ul>
</li>
<li>pringframework.boot.autoconfigure.EnableAutoConfiguration” -&gt;<ul>
<li>org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration</li>
<li>org.springframework.cloud.autoconfigure.LifecycleMvcEndpointAutoConfiguration</li>
<li>org.springframework.cloud.autoconfigure.RefreshAutoConfiguration</li>
<li>org.springframework.cloud.autoconfigure.RefreshEndpointAutoConfiguration</li>
<li>org.springframework.cloud.autoconfigure.WritableEnvironmentEndpointAutoConfiguration”</li>
</ul>
</li>
</ul>
</li>
<li><p>jar:file:&#x2F;C:&#x2F;Users&#x2F;SCWANG&#x2F;.m2&#x2F;repository&#x2F;org&#x2F;springframework&#x2F;boot&#x2F;spring-boot-autoconfigure&#x2F;2.7.18&#x2F;spring-boot-autoconfigure-2.7.18.jar!&#x2F;META-INF&#x2F;spring.factories</p>
</li>
<li><p>properties:</p>
<ul>
<li>org.springframework.boot.sql.init.dependency.DatabaseInitializerDetector” -&gt;<ul>
<li>org.springframework.boot.autoconfigure.flyway.FlywayMigrationInitializerDatabaseInitializerDetector”</li>
</ul>
</li>
<li>org.springframework.boot.autoconfigure.template.TemplateAvailabilityProvider” -&gt;<ul>
<li>org.springframework.boot.autoconfigure.freemarker.FreeMarkerTemplateAvailabilityProvider</li>
<li>org.springframework.boot.autoconfigure.mustache.MustacheTemplateAvailabilityProvider</li>
<li>org.springframework.boot.autoconfigure.groovy.template.GroovyTemplateAvailabilityProvider</li>
<li>org.springframework.boot.autoconfigure.thymeleaf.ThymeleafTemplateAvailabilityProvider</li>
<li>org.springframework.boot.autoconfigure.web.servlet.JspTemplateAvailabilityProvider”</li>
</ul>
</li>
<li>org.springframework.boot.env.EnvironmentPostProcessor” -&gt;<ul>
<li>org.springframework.boot.autoconfigure.integration.IntegrationPropertiesEnvironmentPostProcessor”</li>
</ul>
</li>
<li>org.springframework.context.ApplicationContextInitializer” -&gt;<ul>
<li>org.springframework.boot.autoconfigure.SharedMetadataReaderFactoryContextInitializer</li>
<li>org.springframework.boot.autoconfigure.logging.ConditionEvaluationReportLoggingListener”</li>
</ul>
</li>
<li>org.springframework.boot.diagnostics.FailureAnalyzer” -&gt;<ul>
<li>org.springframework.boot.autoconfigure.data.redis.RedisUrlSyntaxFailureAnalyzer</li>
<li>org.springframework.boot.autoconfigure.diagnostics.analyzer.NoSuchBeanDefinitionFailureAnalyzer</li>
<li>org.springframework.boot.autoconfigure.flyway.FlywayMigrationScriptMissingFailureAnalyzer</li>
<li>org.springframework.boot.autoconfigure.jdbc.DataSourceBeanCreationFailureAnalyzer</li>
<li>org.springframework.boot.autoconfigure.jdbc.HikariDriverConfigurationFailureAnalyzer</li>
<li>org.springframework.boot.autoconfigure.jooq.NoDslContextBeanFailureAnalyzer</li>
<li>org.springframework.boot.autoconfigure.r2dbc.ConnectionFactoryBeanCreationFailureAnalyzer</li>
<li>org.springframework.boot.autoconfigure.r2dbc.MissingR2dbcPoolDependencyFailureAnalyzer</li>
<li>org.springframework.boot.autoconfigure.r2dbc.MultipleConnectionPoolConfigurationsFailureAnalyzer</li>
<li>org.springframework.boot.autoconfigure.r2dbc.NoConnectionFactoryBeanFailureAnalyzer</li>
<li>org.springframework.boot.autoconfigure.session.NonUniqueSessionRepositoryFailureAnalyzer”</li>
</ul>
</li>
<li>org.springframework.boot.sql.init.dependency.DependsOnDatabaseInitializationDetector” -&gt;<ul>
<li>org.springframework.boot.autoconfigure.batch.JobRepositoryDependsOnDatabaseInitializationDetector</li>
<li>org.springframework.boot.autoconfigure.quartz.SchedulerDependsOnDatabaseInitializationDetector</li>
<li>org.springframework.boot.autoconfigure.session.JdbcIndexedSessionRepositoryDependsOnDatabaseInitializationDetector”</li>
</ul>
</li>
<li>org.springframework.boot.autoconfigure.AutoConfigurationImportListener” -&gt;<ul>
<li>org.springframework.boot.autoconfigure.condition.ConditionEvaluationReportAutoConfigurationImportListener”</li>
</ul>
</li>
<li>org.springframework.context.ApplicationListener” -&gt;<ul>
<li>org.springframework.boot.autoconfigure.BackgroundPreinitializer”</li>
</ul>
</li>
<li>org.springframework.boot.autoconfigure.AutoConfigurationImportFilter” -&gt;<ul>
<li>org.springframework.boot.autoconfigure.condition.OnBeanCondition</li>
<li>org.springframework.boot.autoconfigure.condition.OnClassCondition</li>
<li>org.springframework.boot.autoconfigure.condition.OnWebApplicationCondition”</li>
</ul>
</li>
</ul>
</li>
<li><p>jar:file:&#x2F;C:&#x2F;Users&#x2F;SCWANG&#x2F;.m2&#x2F;repository&#x2F;org&#x2F;springframework&#x2F;boot&#x2F;spring-boot&#x2F;2.7.18&#x2F;spring-boot-2.7.18.jar!&#x2F;META-INF&#x2F;spring.factories</p>
</li>
<li><p>properties:</p>
<ul>
<li>org.springframework.boot.sql.init.dependency.DatabaseInitializerDetector -&gt; <ul>
<li>org.springframework.boot.flyway.FlywayDatabaseInitializerDetector</li>
<li>org.springframework.boot.jdbc.AbstractDataSourceInitializerDatabaseInitializerDetector</li>
<li>org.springframework.boot.jdbc.init.DataSourceScriptDatabaseInitializerDetector</li>
<li>org.springframework.boot.liquibase.LiquibaseDatabaseInitializerDetector</li>
<li>org.springframework.boot.orm.jpa.JpaDatabaseInitializerDetector</li>
<li>org.springframework.boot.r2dbc.init.R2dbcScriptDatabaseInitializerDetector</li>
</ul>
</li>
<li>org.springframework.boot.env.PropertySourceLoader -&gt; <ul>
<li>org.springframework.boot.env.PropertiesPropertySourceLoader</li>
<li>org.springframework.boot.env.YamlPropertySourceLoader</li>
</ul>
</li>
<li>org.springframework.boot.logging.LoggingSystemFactory -&gt; <ul>
<li>org.springframework.boot.logging.logback.LogbackLoggingSystem.Factory</li>
<li>org.springframework.boot.logging.log4j2.Log4J2LoggingSystem.Factory</li>
<li>org.springframework.boot.logging.java.JavaLoggingSystem.Factory</li>
</ul>
</li>
<li>org.springframework.boot.context.config.ConfigDataLoader -&gt; <ul>
<li>org.springframework.boot.context.config.ConfigTreeConfigDataLoader</li>
<li>org.springframework.boot.context.config.StandardConfigDataLoader</li>
</ul>
</li>
<li>org.springframework.boot.SpringApplicationRunListener -&gt; <ul>
<li>org.springframework.boot.context.event.EventPublishingRunListener</li>
</ul>
</li>
<li>org.springframework.boot.diagnostics.FailureAnalysisReporter -&gt;<ul>
<li>org.springframework.boot.diagnostics.LoggingFailureAnalysisReporter”</li>
</ul>
</li>
<li>org.springframework.boot.env.EnvironmentPostProcessor -&gt;<ul>
<li>org.springframework.boot.cloud.CloudFoundryVcapEnvironmentPostProcessor</li>
<li>org.springframework.boot.context.config.ConfigDataEnvironmentPostProcessor</li>
<li>org.springframework.boot.env.RandomValuePropertySourceEnvironmentPostProcessor</li>
<li>org.springframework.boot.env.SpringApplicationJsonEnvironmentPostProcessor</li>
<li>org.springframework.boot.env.SystemEnvironmentPropertySourceEnvironmentPostProcessor</li>
<li>org.springframework.boot.reactor.DebugAgentEnvironmentPostProcessor”</li>
</ul>
</li>
<li>org.springframework.boot.SpringBootExceptionReporter -&gt;<ul>
<li>org.springframework.boot.diagnostics.FailureAnalyzers”</li>
</ul>
</li>
<li>org.springframework.context.ApplicationContextInitializer -&gt;<ul>
<li>org.springframework.boot.context.ConfigurationWarningsApplicationContextInitializer</li>
<li>org.springframework.boot.context.ContextIdApplicationContextInitializer</li>
<li>org.springframework.boot.context.config.DelegatingApplicationContextInitializer</li>
<li>org.springframework.boot.rsocket.context.RSocketPortInfoApplicationContextInitializer</li>
<li>org.springframework.boot.web.context.ServerPortInfoApplicationContextInitializer”</li>
</ul>
</li>
<li>org.springframework.boot.diagnostics.FailureAnalyzer -&gt;<ul>
<li>org.springframework.boot.context.config.ConfigDataNotFoundFailureAnalyzer</li>
<li>org.springframework.boot.context.properties.IncompatibleConfigurationFailureAnalyzer</li>
<li>org.springframework.boot.context.properties.NotConstructorBoundInjectionFailureAnalyzer</li>
<li>org.springframework.boot.diagnostics.analyzer.BeanCurrentlyInCreationFailureAnalyzer</li>
<li>org.springframework.boot.diagnostics.analyzer.BeanDefinitionOverrideFailureAnalyzer</li>
<li>org.springframework.boot.diagnostics.analyzer.BeanNotOfRequiredTypeFailureAnalyzer</li>
<li>org.springframework.boot.diagnostics.analyzer.BindFailureAnalyzer</li>
<li>org.springframework.boot.diagnostics.analyzer.BindValidationFailureAnalyzer</li>
<li>org.springframework.boot.diagnostics.analyzer.UnboundConfigurationPropertyFailureAnalyzer</li>
<li>org.springframework.boot.diagnostics.analyzer.MutuallyExclusiveConfigurationPropertiesFailureAnalyzer</li>
<li>org.springframework.boot.diagnostics.analyzer.NoSuchMethodFailureAnalyzer</li>
<li>org.springframework.boot.diagnostics.analyzer.NoUniqueBeanDefinitionFailureAnalyzer</li>
<li>…</li>
</ul>
</li>
<li>org.springframework.boot.ApplicationContextFactory -&gt;<ul>
<li>org.springframework.boot.web.reactive.context.AnnotationConfigReactiveWebServerApplicationContext.Factory</li>
<li>org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext.Factory”</li>
</ul>
</li>
<li>org.springframework.boot.sql.init.dependency.DependsOnDatabaseInitializationDetector -&gt;<ul>
<li>org.springframework.boot.sql.init.dependency.AnnotationDependsOnDatabaseInitializationDetector</li>
<li>org.springframework.boot.jdbc.SpringJdbcDependsOnDatabaseInitializationDetector</li>
<li>org.springframework.boot.jooq.JooqDependsOnDatabaseInitializationDetector</li>
<li>org.springframework.boot.orm.jpa.JpaDependsOnDatabaseInitializationDetector”</li>
</ul>
</li>
<li>org.springframework.boot.context.config.ConfigDataLocationResolver -&gt;<ul>
<li>org.springframework.boot.context.config.ConfigTreeConfigDataLocationResolver</li>
<li>org.springframework.boot.context.config.StandardConfigDataLocationResolver”</li>
</ul>
</li>
<li>org.springframework.context.ApplicationListener -&gt;<ul>
<li>org.springframework.boot.ClearCachesApplicationListener</li>
<li>org.springframework.boot.builder.ParentContextCloserApplicationListener</li>
<li>org.springframework.boot.context.FileEncodingApplicationListener</li>
<li>org.springframework.boot.context.config.AnsiOutputApplicationListener</li>
<li>org.springframework.boot.context.config.DelegatingApplicationListener</li>
<li>org.springframework.boot.context.logging.LoggingApplicationListener</li>
<li>org.springframework.boot.env.EnvironmentPostProcessorApplicationListener”</li>
</ul>
</li>
</ul>
</li>
</ul>

      </section>
      <section class="extra">
        
          <ul class="copyright">
  
    <li><strong>本文作者：</strong>scwang90</li>
    <li><strong>本文链接：</strong><a href="https://blog.scwang90.cn/2024/05/23/spring-boot-config-study/index.html" title="https:&#x2F;&#x2F;blog.scwang90.cn&#x2F;2024&#x2F;05&#x2F;23&#x2F;spring-boot-config-study&#x2F;index.html">https:&#x2F;&#x2F;blog.scwang90.cn&#x2F;2024&#x2F;05&#x2F;23&#x2F;spring-boot-config-study&#x2F;index.html</a></li>
    <li><strong>版权声明：</strong>本分享所有文章均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/deed.zh" title="BY-NC-SA" target="_blank" rel="noopener">BY-NC-SA</a> 许可协议，转载请注明出处！</li>
  
</ul>
        
        
        
  <ul class="tag-list" itemprop="keywords"><li class="tag-list-item"><a class="tag-list-link" href="/tags/config/" rel="tag">config</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/spring/" rel="tag">spring</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/%E6%BA%90%E7%A0%81/" rel="tag">源码</a></li></ul> 

        
  <nav class="nav">
    <a href="/2024/07/11/spring-boot-admin-study/"><i class="iconfont iconleft"></i>SpringBootAdmin 学习探究</a>
    <a href="/2024/05/20/version-manager-nvm/">NVM：Node Version Manager，Node.js版本控制的艺术<i class="iconfont iconright"></i></a>
  </nav>

      </section>
      
    </section>
  </div>
</article></div>
        <div class="col-xl-2">
          
            
  <aside class="toc-wrap">
    <h3 class="toc-title">文章目录：</h3>
    <ol class="toc"><li class="toc-item toc-level-2"><a class="toc-link" href="#SpringBoot-%E9%9B%86%E6%88%90-NacosRegister-%E6%BA%90%E7%A0%81%E5%90%AF%E5%8A%A8%E9%A1%BA%E5%BA%8F"><span class="toc-text">SpringBoot 集成 NacosRegister 源码启动顺序</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#com-alibaba-nacos-core-code-SpringApplicationRunListener-nacos-%E7%9B%91%E5%90%AC%E5%88%B0%E4%BA%8B%E4%BB%B6"><span class="toc-text">com.alibaba.nacos.core.code.SpringApplicationRunListener [nacos 监听到事件]</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#spring-factories-%E5%BE%AA%E7%8E%AF%E8%AF%BB%E5%8F%96%E5%AE%8C%E6%95%B4%E7%89%88"><span class="toc-text">spring.factories 循环读取完整版</span></a></li></ol>
  </aside>

          
        </div>
      </div>
    
  </div>
</main>
  

<footer class="footer">
  <div class="footer-social"><a 
        href="tencent://message/?Menu=yes&uin=283371828 "
        target="_blank"
        class="footer-social-item"
        onMouseOver="this.style.color= '#12B7F5'" 
        onMouseOut="this.style.color='#33333D'">
          <i class="iconfont  iconQQ "></i>
      </a><a 
        href="javascript:; "
        target="_blank"
        class="footer-social-item"
        onMouseOver="this.style.color= '#09BB07'" 
        onMouseOut="this.style.color='#33333D'">
          <i class="iconfont  iconwechat-fill "></i>
      </a><a 
        href="https://github.com/scwang90 "
        target="_blank"
        class="footer-social-item"
        onMouseOver="this.style.color= '#9f7be1'" 
        onMouseOut="this.style.color='#33333D'">
          <i class="iconfont  icongithub-fill "></i>
      </a><a 
        href="mailto:scwang90@hotmail.com "
        target="_blank"
        class="footer-social-item"
        onMouseOver="this.style.color=#FF3B00" 
        onMouseOut="this.style.color='#33333D'">
          <i class="iconfont  iconmail"></i>
      </a></div>
  
    <div class="footer-copyright"><p>Powered by <a target="_blank" href="https://github.com/scwang90">scwang90</a>  |  Theme - <a target="_blank" href="https://github.com/izhaoo/hexo-theme-zhaoo">zhaoo</a></p> <p><a target="_blank" href="http://beian.miit.gov.cn/"><span>黔ICP备2021004317号-1</span></a><span>  |  </span><a target="_blank" href="http://www.beian.gov.cn/portal/registerSystemInfo" style="display:inline-block;text-decoration:none;height:20px;line-height:20px;"><img class="lazyload" data-original="/images/icons/icon-filing.png" src="https://www.beian.gov.cn/img/new/gongan.png"/> <span> 贵公网安备 52010202002539号</span></a></p></div>
  
</footer>
  
      <div class="fab fab-plus">
    <i class="iconfont iconplus"></i>
  </div>
  
  
  
  <div class="fab fab-up">
    <i class="iconfont iconcaret-up"></i>
  </div>
  
  
  
    
<script src="/js/color-mode.js"></script>

  
  
</body>

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>





  
<script src="https://cdn.bootcdn.net/ajax/libs/jquery.lazyload/1.9.1/jquery.lazyload.min.js"></script>




  
<script src="https://cdnjs.cloudflare.com/ajax/libs/fancybox/3.5.7/jquery.fancybox.min.js"></script>






  
<script src="https://cdn.bootcdn.net/ajax/libs/jquery.qrcode/1.0/jquery.qrcode.min.js"></script>




<script src="/js/utils.js"></script>
<script src="/js/script.js"></script>







  <script>
    (function () {
      var bp = document.createElement('script');
      var curProtocol = window.location.protocol.split(':')[0];
      if (curProtocol === 'https') {
        bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';
      } else {
        bp.src = 'http://push.zhanzhang.baidu.com/push.js';
      }
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(bp, s);
    })();
  </script>













</html>